package com.labor_management_system.Controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.labor_management_system.Entity.User;
import com.labor_management_system.Service.AttendanceService;
import com.labor_management_system.Service.UnionService;
import com.labor_management_system.Service.UserService;
import com.labor_management_system.Utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
public class UserController {
    @Autowired
    UserService userService;
    @PostMapping("/POST/Login")
    public R login(@RequestBody User user){
        return userService.getBaseMapper().selectCount(new QueryWrapper<User>()
                .eq("user_name",user.getUserName())
                .eq("password",user.getPassword()))==1?R.ok():R.error().message("用户名或密码不正确");
    }
    @PostMapping("/POST/Register")
    public R register(@RequestBody User user){
        return userService.getBaseMapper().insert(user)>0?R.ok():R.error().message("用户名重复");
    }

}
